from django import template
from ..models import Article, Categroy

register = template.Library()


@register.simple_tag
def get_recent_posts(num=5):
    return Article.objects.all()[:num]


@register.simple_tag
def archives():
    return Article.objects.dates('created', 'month', order='DESC')


@register.simple_tag
def get_categories():
    return Categroy.objects.all()
